export function getIndexBy<T, K extends keyof T>(ts: T[], key: K, value: T[K]) {
  return ts.findIndex((t) => t[key] === value);
}

export function getBy<T, K extends keyof T>(ts: T[], key: K, value: T[K]) {
  const index = ts.findIndex((t) => t[key] === value);
  return index !== -1 ? ts[index] : undefined;
}

export function move<T>(ts: T[], oldIndex: number, newIndex: number) {
  ts.splice(newIndex, 0, ts.splice(oldIndex, 1)[0]);
  return ts;
}
